<script type="text/javascript" src="{lib file=groupinfo.js}" charset="utf-8"></script>
<script type="text/javascript">
//<!CDATA[
    /* buy */
    function buy()
    {
		var gid = '{$goods.gid}';//增加团购id添加到购物车
	var max_per_user = '{$goods.max_per_user}';
	var max_per_user_desc = '{$goods.max_per_user_desc}';
        if (goodsspec.getSpec() == null)
        {
            alert(lang.select_specs);
            return;
        }
        var spec_id = goodsspec.getSpec().id;

        var quantity = $("#quantity").val();
        if (quantity == '')
        {
            alert(lang.input_quantity);
            return;
        }
        if (parseInt(quantity) < 1)
        {
            alert(lang.invalid_quantity);
            return;
        }
	if(max_per_user > 0 && parseInt(quantity) > max_per_user)
	{
			alert(max_per_user_desc);
			return;
	}
        add_to_cart(spec_id, quantity, gid);
    }

    /* add cart */
    function add_to_cart(spec_id, quantity, gid)
    {
        var url = 'index.php?app=cart&act=add';

        $.getJSON(url, {'spec_id': spec_id, 'quantity': quantity, 'gid':gid}, function(data) {
            if (data.done)
            {
                $('.bold_num').text(data.retval.cart.kinds);
                $('.bold_mly').html(price_format(data.retval.cart.amount));
                $(".buynow .msg").slideDown().delay(5000).slideUp();
                // $('.msg').slideDown('slow');
                // setTimeout(slideUp_fn, 5000);
            }
            else
            {
                alert(data.msg);
            }
        });
    }

         /*buy_now*/
        function buy_now()
        {
	var gid = '{$goods.gid}';//增加团购id添加到购物车
	var max_per_user = '{$goods.max_per_user}';
	var max_per_user_desc = '{$goods.max_per_user_desc}';
            //验证数据
            if (goodsspec.getSpec() == null)
            {
                alert(lang.select_specs);
                return;
            }
            var spec_id = goodsspec.getSpec().id;

            var quantity = $("#quantity").val();
            if (quantity == '')
            {
                alert(lang.input_quantity);
                return;
            }
            if (parseInt(quantity) < 1)
            {
                alert(lang.invalid_quantity);
                return;
            }
            buy_now_add_cart(spec_id, quantity, gid);
        }

        /* add buy_now_add_cart */
        function buy_now_add_cart(spec_id, quantity, gid)
        {
            var url = SITE_URL + '/index.php?app=cart&act=add';
            $.getJSON(url, {'spec_id': spec_id, 'quantity': quantity, 'gid':gid}, function(data) {
                if (data.done)
                {
                    location.href = SITE_URL + '/index.php?app=order&goods=cart&store_id={$store.store_id}';
                } else {
                    alert(data.msg);
                }
            });
        }



var specs = new Array();
<!--{foreach from=$goods._specs item=spec}-->
<!--{if $spec.group_price}-->
specs.push(new spec({$spec.spec_id}, '{$spec.spec_1|escape}', '{$spec.spec_2|escape}', '{$spec.spec_3|escape}', '{$spec.spec_4|escape}', {$spec.price},{$spec.group_price}, {$spec.stock}));
<!--{else}-->
specs.push(new spec({$spec.spec_id}, '{$spec.spec_1|escape}', '{$spec.spec_2|escape}', '{$spec.spec_3|escape}', '{$spec.spec_4|escape}', {$spec.price},0, {$spec.stock}));
<!--{/if}-->
<!--{/foreach}-->
var specQty = {$goods.spec_qty};
var defSpec = {$goods.default_spec|escape};
var goodsspec = new goodsspec(specs, specQty, defSpec);
//]]>
</script>
<div class="detail_img">
    <div id="slider" class="slider" >
        <ul id="sliderlist" class="sliderlist" >
            <!--{foreach from=$goods._images item=goods_image name=fe_goods_image}-->
            <li><img src="{$site_url}/{$goods_image.thumbnail}"></li>
            <!--{/foreach}-->
        </ul>
    </div>
    <script type="text/javascript">
        var t2 = new TouchSlider({id: 'sliderlist', speed: 600, timeout: 3000, before: function(index) {
            }});
    </script>

    <p class="line"></p>
</div>

<div class="detail_tit">
    <p>{$goods.goods_name|escape}</p>

    <p>{$lang.group_purchase_price}：<strong ectype="goods_group_price">{$goods._specs.0.group_price|price}</strong></p>

    <!--{if $store.enable_free_fee}-->
    <!--{if $store.amount_for_free_fee neq '0.00'}--><p>{$lang.man}{$store.amount_for_free_fee|price}{$lang.yuan_shipping}</p><!--{/if}-->
    <!--{if $store.acount_for_free_fee}--><p>{$lang.man}{$store.acount_for_free_fee|escape}{$lang.jian_shipping}</p><!--{/if}-->
    <!--{/if}-->
    {if $goods.integral_max_exchange}<p>{$lang.can_use_integral}:<strong style="color:red;font-weight: bold;padding-left:10px;">{$goods.integral_max_exchange|escape}</strong></p>{/if}
    <p>{$lang.sales_volume}：{$sales_info}{$comments}</p>
    <p><span>{$lang.region}：{$store.region_name|escape}</span></p>
</div>
<div class="detail_size">
    <div class="size_con">
        <div class="handle">
            <!--{if $goods.spec_name_1}-->
            <ul id='handle_1'>
                <li class="handle_title">{$goods.spec_name_1|escape}: </li>
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_name_2}-->
            <ul id='handle_2'>
                <li class="handle_title">{$goods.spec_name_2|escape}: </li>
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_name_3}-->
            <ul id='handle_3'>
                <li class="handle_title">{$goods.spec_name_3|escape}: </li>
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_name_4}-->
            <ul id='handle_4'>
                <li class="handle_title">{$goods.spec_name_4|escape}: </li>
            </ul>
            <!--{/if}-->
            <ul class="quantity">
                <li class="handle_title">{$lang.quantity}: </li>
                <li>
                    <input type="text" class="text width1" name="" id="quantity" value="1" />
                    {$lang.unit} {$lang.left_bracket}{$lang.stock}<span class="stock" ectype="goods_stock">{$goods._specs.0.stock}</span>{$lang.unit}{$lang.right_bracket}
                </li>
            </ul>
            <!--{if $goods.spec_qty gt 0}-->
            <ul class="selected">
                <li class="handle_title">{$lang.your_select}: </li>
                <li class="aggregate" ectype="current_spec"></li>
            </ul>
            <!--{/if}-->
        </div>
        <div class="buynow">
            <a href="javascript:buy_now();" class="buy">{$lang.purchase_now}</a><a href="javascript:buy();" class="add">{$lang.add_to_cart}</a>
            <div class="msg" style="display:none;">
                <p><b></b>{$lang.Shopping_common}<span class="bold_num"></span>{$lang.In_total} <span class="bold_mly" style="color:#8D0303;"></span>！</p>
                <a href="{url app=cart}" class="white_btn">{$lang.view_cart}</a>
                <a  onclick="$('.msg').css({'display': 'none'});" class="white_btn">{$lang.continue_shopping}</a>
            </div>
        </div>
    </div>
</div>
<dl class="list_entry clearfix">
    <dt>
        <a href="{url app=store&id=$store.store_id}">{$store.store_name|escape}</a><!--{if $store.credit_value ge 0}--><img src="{$site_url}/{$store.credit_image}" alt="" /><!--{/if}-->
    </dt>				
    <dd>
        <a href="http://wpa.qq.com/msgrd?v=3&uin={$store.im_qq}&site=qq&menu=yes"><i class="icon_dong"></i>{$lang.Contact_customer_service}</a>
    </dd>
</dl>
    